package cn.edu.tsinghua.smxq.mobilecity.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.edu.tsinghua.smxq.mobilecity.po.FoodQuote;
import cn.edu.tsinghua.smxq.mobilecity.utils.DBUtils;

public class FoodQuoteDAO {
	
	public boolean create(FoodQuote foodQuote) throws SQLException {
		boolean success = false;
		Connection conn = DBUtils.Connect();
		PreparedStatement pstmt = conn
				.prepareStatement("INSERT INTO mobilecity.foodquote(userid,cityid,foodid,price,pricedate,time) values(?,?,?,?,?,?)");
		pstmt.setInt(1, foodQuote.getUserId());
		pstmt.setInt(2, foodQuote.getCityId());
		pstmt.setInt(3, foodQuote.getFoodId());
		pstmt.setFloat(4, foodQuote.getPrice());
		pstmt.setDate(5, foodQuote.getPriceDate());
		pstmt.setTimestamp(6, foodQuote.getTime());
	
		if (pstmt.executeUpdate() == 1) {
			success = true;
		}
		pstmt.close();
		conn.close();
		return success;
	}

}
